'''
@Author: your name
@Date: 2020-05-14 23:49:42
@LastEditTime: 2020-05-18 04:43:09
@LastEditors: Please set LastEditors
@Description: In User Settings Edit
@FilePath: \Gitee\selenium_project\testCase\TestLoginCase.py
'''
import unittest
from selenium import webdriver
from page.LoginPage import LoginPage


class LoginCase(unittest.TestCase):

    def setUp(self):
        self.fox = webdriver.Chrome()
        self.baseurl = "http://deng.lovewx999.xyz:8080/demo/"
        self.title = "登录"

    def test_login(self):
        """
        正确用户名和密码登录失败
        :return:
        """
        loginPage = LoginPage(self.fox, self.baseurl, self.title)
        loginPage.open()
        loginPage.input_username("admin")
        loginPage.input_password("123")
        loginPage.click_submit()
        self.assertEqual(self.fox.title, u"登录", "错误的用户名和错误的密码，登录失败")

    def testb(self):
        """
        不正确用户名和密码登录成功！
        :return:
        """
        loginPage = LoginPage(self.fox, self.baseurl, self.title)
        loginPage.open()
        loginPage.input_username("root")
        loginPage.input_password("123456")
        loginPage.click_submit()
        self.assertEqual(self.fox.title, u"学生列表", "正确用户名和密码登录成功！")

    def tearDown(self):
        self.fox.quit()
